var self_id,cur_page = 1;
var resArry = [];
var nomore = false;
var app = angular.module("dynamicApp", []);
app.controller("dynamicController", function($scope, $http) {
	$scope.initView = function($id) {
		if(nomore){return;}		
		plus.nativeUI.showWaiting('加载中...');
		$http({
			method: 'post',
			url: apiRoot,
			data: {
				action: 'Dynamic.index',
				uid:self_id,
				page:cur_page
			}
		}).then(function successCallback(response) {
			plus.nativeUI.closeWaiting(); 
			if(response.data.data == undefined){
				$scope.not_more  = 1;
				nomore = true;
				return;
			}
			resArry.push(response.data.data);
			$scope.res = resArry; //最新内容数据 	
		}, function errorfunction(e) {  
			console.log(JSON.stringify(e));
			plus.nativeUI.closeWaiting();
		})
	}   

	$scope.dynamicData = function(uid,status,id) {
		if(status == 0) {
			openPage("view_detail.html", { noteUid:uid,type:status,noteId:id});
		} else if(status == 1) {
			openPage("goods_detail.html", { gUid:uid,type:status,gId:id });
		}
	}
})

document.addEventListener("plusready", function() {
	appElement = document.querySelector('[ng-controller=dynamicController]');
	$scope = angular.element(appElement).scope();
	self_id = plus.storage.getItem('uid');
	$scope.initView();
	$scope.$apply();	
})

